<?php
namespace app\admin\controller;
use think\Request;

/**
 * 网站系统管理
 */
class System extends Base
{
	public $req;
	protected $SystemModel;

	public function __construct()
	{
		parent::__construct();
		$this->req = Request::instance();
		$this->SystemModel = model('SystemModel');
	}

	/**
	 * 系统基本参数
	 */
	public function systemBaseParams()
	{
		if ($this->req->isPost()) {
			$data = $this->req->post();
			$data = json_encode($data);
			$res = $this->SystemModel->save(['systemBaseParams' => $data],['id' => 1]);
			if (!$res) {
				return show(1, '数据更新失败');
			}
			return show(0, '数据更新成功');

		} else {
			$params = $this->SystemModel->get(1);
			$params = json_decode($params['systemBaseParams'], true);
			// halt($params);
			return $this->fetch('system/systemBaseParams', ['params'=>$params]);
		}

		/*$data = [
			'cfg_basehost' => '',
			'cfg_indexurl' => '',
			'cfg_webname' => '',
			'cfg_powerby' => '',
			'cfg_keywords' => '',
			'cfg_description' => '',
			'cfg_beian' => ''
		];
		echo json_encode($data);


		{"cfg_basehost": "","cfg_indexurl": "","cfg_webname": "","cfg_powerby": "","cfg_keywords": "","cfg_description": "","cfg_beian": ""}*/


	}

	// //首页静态化
	// public function indexStatically()
	// {
	// 	$count = file_get_contents('index/index.html');
	// 	echo $count;die;

	// }

}